package com.city.ossservice.controller;

import com.city.commonutils.Result;
import com.city.ossservice.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * Created with IntelliJ IDEA.
 * User: Cheng
 * Date: 2020/6/14
 * Time: 23:11
 * Description: No Description
 */
@RestController
@RequestMapping("/eduoss/fileoss")
@CrossOrigin
public class OssController {
    @Autowired
    private OssService ossService;
    //头像上传接口
    @PostMapping
    public Result uploadOssFile(MultipartFile file){
        //获取上传的头像文件  MultipartFile
        //service上传到oss返回图片地址存放到数据库
        String url=ossService.uploadOssFileAvatar(file);
        return Result.ok().data("url",url);
    }
}
